home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue30 / pathed3 / PATHED3.ZIP / Source / SolutionsUnlimitedPathEd.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-12-28  |  20.2 KB  |  770 lines

  1. {-------------------------------------------------------------------------------
  2. Name                    :    SolutionsUnlimitedPathEd.pas
  3. Author                : Robert Kozak
  4. Date                    : November 1, 1997
  5.  
  6. Copyright            : ⌐ 1997 Solutions Unlimited. All Rights Reserved.
  7.  
  8. Version             : 1.0
  9. Last Updated    :
  10.  
  11. Description        : This is an expert for managing the Paths in Delphi.
  12.  
  13. Notes:
  14. -------------------------------------------------------------------------------}
  15. unit SolutionsUnlimitedPathEd;
  16.  
  17. interface
  18.  
  19. uses
  20.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  21.   ComCtrls, Registry, StdCtrls, ExptIntf, ToolIntf, Placemnt,
  22.   ExtCtrls, rkCommon, Menus, checklst, SolutionsUnlimitedBrowseFolder, rkAboutForm;
  23.  
  24. const
  25.   DELPHI_3_PATHHISTORY        = '\Software\Borland\Delphi\3.0\HistoryList\hiLibraryPath';
  26.     DELPHI_3_PATH                             = '\Software\Borland\Delphi\3.0\Library\';
  27.     DELPHI_3_FULLPATH                        = '\Software\Borland\Delphi\3.0\Library\FULLPath\';
  28.     DELPHI_3_KNOWN_PACKAGES         = '\Software\Borland\Delphi\3.0\Known Packages';
  29.     DELPHI_3_DISABLED_PACKAGES    = '\Software\Borland\Delphi\3.0\Disabled Packages';
  30.  
  31.   DELPHI_3_SOLUTIONS                    = '\Software\Borland\Delphi\3.0\Solutions\';
  32.     DELPHI_3_PATH_KEY                        = 'SearchPath';
  33.  
  34. type
  35.   TPathEdExpert = class(TIExpert)
  36.   private
  37.     fMenuItem: TIMenuItemIntf;
  38.     procedure MenuClick(Sender: TIMenuItemIntf);
  39.     procedure NewWndProc(var Msg : TMessage); virtual;
  40.     protected
  41.         procedure PreProcessMsg(Sender: TObject; var msg: TMessage; var bContinue: Boolean);
  42.     procedure PostProcessMsg(Sender: TObject; var msg: TMessage; var bContinue: Boolean);
  43.         procedure UpdateDelphiPath;
  44.   public
  45.         constructor Create;
  46.     destructor Destroy; override;
  47.     procedure Execute; override;
  48.     function GetAuthor: string; override;
  49.     function GetComment: string; override;
  50.     function GetGlyph: HICON; override;
  51.     function GetIDString: string; override;
  52.     function GetMenuText: string; override;
  53.     function GetName: string; override;
  54.     function GetPage: string; override;
  55.     function GetState: TExpertState; override;
  56.     function GetStyle: TExpertStyle; override;
  57.     property MenuItem: TIMenuItemIntf read fMenuItem;
  58.   end;
  59.  
  60.   TfrmSetPath = class(TForm)
  61.     Panel1: TPanel;
  62.     btnDown: TButton;
  63.     btnAdd: TButton;
  64.     btnUp: TButton;
  65.     btnRemove: TButton;
  66.     StatusBar1: TStatusBar;
  67.     FormStorage: TFormStorage;
  68.     pnlList: TPanel;
  69.     TabControl1: TTabControl;
  70.     btnOptions: TButton;
  71.     PopupMenu1: TPopupMenu;
  72.     Sort1: TMenuItem;
  73.     btnClose: TButton;
  74.     lstPath: TCheckListBox;
  75.     N1: TMenuItem;
  76.     About1: TMenuItem;
  77.     procedure btnAddClick(Sender: TObject);
  78.     procedure btnRemoveClick(Sender: TObject);
  79.     procedure btnUpClick(Sender: TObject);
  80.     procedure btnDownClick(Sender: TObject);
  81.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  82.     procedure FormCreate(Sender: TObject);
  83.     procedure FormStorageRestorePlacement(Sender: TObject);
  84.     procedure btnOptionsClick(Sender: TObject);
  85.     procedure Sort1Click(Sender: TObject);
  86.     procedure About1Click(Sender: TObject);
  87.   private
  88.     { Private declarations }
  89.     FDisplayHistory : Boolean;
  90.     FDisplayPackagePath: Boolean;
  91.     FDisplayProject : Boolean;
  92.     FSyncPackages : Boolean;
  93.         OldList : TStringList;
  94.     PackagePath : TStringList;
  95.     procedure SaveList;
  96.     procedure RestoreList;
  97.     function ListSaved : Boolean;
  98.     procedure ParsePath;
  99.       procedure WritePath;
  100.       procedure ReadPath;
  101.     procedure SyncWithPackages;
  102.     procedure AddSubDirs(Sender: TObject);
  103.   protected
  104.     procedure SetDisplayPackagePath(Value : Boolean);
  105.     procedure SetSyncPackages(Value : Boolean);
  106.   public
  107.     { Public declarations }
  108.     property DisplayPackagePath: Boolean read FDisplayPackagePath write SetDisplayPackagePath;
  109.     property SyncPackages : Boolean read FSyncPackages write SetSyncPackages;
  110.   end;
  111.  
  112.     procedure Register;
  113.  
  114. var
  115.   frmSetPath: TfrmSetPath;
  116.     WindowHook : HHook;
  117.   DoSubClass : Boolean;
  118.     PathEdExpert : TPathEdExpert;
  119.   Path : string;
  120.  
  121. implementation
  122.  
  123. uses
  124.   SolutionsUnlimitedPathOptions;
  125.  
  126. resourcestring
  127.   sName = 'Library Search Path Expert';
  128.   sMenuText = 'Edit Library Search &Path...';
  129.   sMenuName = 'EditLibrarySearchPathItem';
  130.  
  131. {$R *.DFM}
  132.  
  133. var
  134.   NewWndProcPointer : TFarProc;
  135.   OrgWndProcPointer : LongInt;
  136.   WindowHandle : HWnd;
  137.  
  138. procedure TPathEdExpert.NewWndProc(var Msg : TMessage);
  139. //function NewWndProc(Handle : HWND; Msg : UInt; wparam : WPARAM; lparam: LPARAM): LRESULT; stdcall;
  140. var
  141.     EnvDialog : TCustomForm;
  142.   LibraryTab :  TTabSheet;
  143.  
  144.   PathCombo : TComboBox;
  145.   temp : string;
  146.  
  147. begin
  148.   case Msg.Msg of
  149.     WM_WINDOWPOSCHANGING :
  150.     begin
  151.         TWindowPos(pWindowPos(Msg.Lparam)^).cx := 0;
  152.         TWindowPos(pWindowPos(Msg.Lparam)^).cy := 0;
  153.       Msg.Result := 0;
  154.     end;
  155.  
  156.         CM_ACTIVATE:
  157.           if Application.FindComponent('EnvDialog') <> nil then
  158.         begin
  159.             EnvDialog := TForm(Application.FindComponent('EnvDialog'));
  160.           EnvDialog.ModalResult := mrOK;
  161.            PathCombo := TComboBox(EnvDialog.FindComponent('LibOptionsDlg2').FindComponent('ecLibraryPath'));
  162.         PathCombo.Text := Path;
  163.           PostMessage(EnvDialog.Handle, CM_DEACTIVATE, 0, 0);
  164.         Msg.Result := 0;
  165.         end;
  166.         CM_DEACTIVATE:
  167.           if Application.FindComponent('EnvDialog') <> nil then
  168.         begin
  169.           EnvDialog := TForm(Application.FindComponent('EnvDialog'));
  170.           EnvDialog.ModalResult := mrOK;
  171.         Msg.Result := 0;
  172.         end;          
  173.  
  174. //  else Result := CallWindowProc(Pointer(OrgWndProcPointer), Handle, Msg, wparam, lparam);
  175.   else Dispatch(Msg);
  176.   end;
  177. end;
  178.  
  179. {------------------------------------------------------------------------------}
  180.  
  181. function Hook(Code : Integer; wparam :WPARAM; lParam : LPARAM): LResult; stdcall;
  182. var
  183.     aClassName : array [0..25] of char;
  184.   i: integer;
  185.  
  186. begin
  187.     with TCWPStruct(PCWPStruct(lparam)^) do
  188.       if (Message = WM_ParentNotify) and (LoWord(wparam) = WM_CREATE) then
  189.         begin
  190.              WindowHandle := GetParent(lParam);
  191.       GetClassName(WindowHandle, aClassName, 25);
  192.  
  193.       if (aClassName = 'TEnvDialog') and (DoSubClass) then
  194.       begin
  195.         FlashWindow(Application.MainForm.Handle, False);
  196.         NewWndProcPointer := MakeObjectInstance(PathEdExpert.NewWndProc);
  197.             OrgWndProcPointer := LongInt(SetWindowLong(WindowHandle, gwl_WndProc, LongInt(NewWndProcPointer)));
  198.       end;
  199.       end;
  200.  
  201.     Result := CallNextHookEx(WindowHook, Code, WParam, Lparam);
  202. end;
  203.  
  204. { TPathEdExpert ---------------------------------------------------------------}
  205.  
  206. constructor TPathEdExpert.Create;
  207. var
  208.     Index : integer;
  209.  
  210. begin
  211.   inherited Create;
  212.  
  213.   with ToolServices.GetMainMenu.FindMenuItem('InstallPackagesItem') do
  214.   begin
  215.       Index := GetIndex + 1;
  216.         fMenuItem := GetParent.InsertItem(Index,sMenuText,sMenuName,'',0,0,0,[mfEnabled,mfVisible],MenuClick);
  217.   end;
  218.  
  219.   WindowHook := SetWindowsHookEx(WH_CALLWNDPROC, @Hook, HInstance, GetCurrentThreadID);
  220. end;
  221.  
  222. {------------------------------------------------------------------------------}
  223.  
  224. destructor TPathEdExpert.Destroy;
  225. begin
  226.   MenuItem.Free;
  227.  
  228.   SetWindowLong(WindowHandle, gwl_WndProc, OrgWndProcPointer);
  229.  
  230.     UnHookWindowsHookEx(WindowHook);
  231.   inherited Destroy;
  232. end;
  233.  
  234. {------------------------------------------------------------------------------}
  235.  
  236. procedure TPathEdExpert.MenuClick(Sender:
  237.    TIMenuItemIntf);
  238. begin
  239.   Execute;
  240. end;
  241. {------------------------------------------------------------------------------}
  242.  
  243. function TPathEdExpert.GetStyle: TExpertStyle;
  244. begin
  245.   Result := esAddIn;
  246. end;
  247.  
  248. {------------------------------------------------------------------------------}
  249.  
  250. function TPathEdExpert.GetName: string;
  251. begin
  252.   Result := sName;
  253. end;
  254.  
  255. {------------------------------------------------------------------------------}
  256.  
  257. function TPathEdExpert.GetIDString: string;
  258. begin
  259.   Result := 'Solutions Unlimited.PathEditor';
  260. end;
  261.  
  262. {------------------------------------------------------------------------------}
  263.  
  264. procedure TPathEdExpert.Execute;
  265. begin
  266.     with TfrmSetPath.Create(nil) do
  267.   try
  268.         ShowModal;
  269.   finally
  270.     Free;
  271.   end;
  272.  
  273.   UpdateDelphiPath;
  274. end;
  275.  
  276. {------------------------------------------------------------------------------}
  277.  
  278. procedure TPathEdExpert.PreProcessMsg(Sender: TObject;
  279.   var msg: TMessage; var bContinue: Boolean);
  280. begin     case msg.msg of
  281.     WM_WINDOWPOSCHANGING :
  282.     begin
  283.         TWindowPos(pWindowPos(Msg.Lparam)^).cx := 0;
  284.         TWindowPos(pWindowPos(Msg.Lparam)^).cy := 0;
  285.     end;
  286.   end;
  287. end;
  288. {------------------------------------------------------------------------------}
  289. procedure TPathEdExpert.PostProcessMsg(Sender: TObject;
  290.   var msg: TMessage; var bContinue: Boolean);var
  291.     EnvDialog : TCustomForm;
  292.   LibraryTab :  TTabSheet;
  293.  
  294.   PathCombo : TComboBox;
  295.   temp : string;
  296.  
  297. begin
  298.   // Hard coding the Component Names for this release. Will create a wrapper Class
  299.   // for Delphi in the next release.
  300.     case Msg.Msg of
  301.         CM_ACTIVATE:
  302.           if Application.FindComponent('EnvDialog') <> nil then
  303.         begin
  304.             EnvDialog := TForm(Application.FindComponent('EnvDialog'));
  305.           EnvDialog.ModalResult := mrOK;
  306.           PathCombo := TComboBox(EnvDialog.FindComponent('LibOptionsDlg2').FindComponent('ecLibraryPath'));
  307.         PathCombo.Text := Path;
  308.           PostMessage(EnvDialog.Handle, CM_DEACTIVATE, 0, 0);
  309.         end;
  310.         CM_DEACTIVATE:
  311.           if Application.FindComponent('EnvDialog') <> nil then
  312.         begin
  313.           EnvDialog := TForm(Application.FindComponent('EnvDialog'));
  314.           EnvDialog.ModalResult := mrOK;
  315.         end;
  316.     end;
  317. end;
  318.  
  319. procedure TPathEdExpert.UpdateDelphiPath;
  320. var
  321.     ABuilder : TForm;
  322.   EnvDialogItem : TMenuItem;
  323.  
  324. begin
  325.     DoSubClass := True;
  326.   if Assigned(Application.FindComponent('AppBuilder')) then
  327.   begin
  328.       ABuilder := TForm(Application.FindComponent('AppBuilder'));
  329.     if Assigned(ABuilder.FindComponent('ToolsOptionsItem')) then
  330.     begin
  331.           EnvDialogItem := TMenuItem(ABuilder.FindComponent('ToolsOptionsItem'));
  332.             EnvDialogItem.Click;
  333.         DoSubClass := False;
  334.       end;
  335.     end;
  336. end;
  337.  
  338. // These methods are not important for an AddIn expert;
  339. {------------------------------------------------------------------------------}
  340.  
  341. function TPathEdExpert.GetAuthor: string;
  342. begin
  343.     Result := ''
  344. end;
  345.  
  346. {------------------------------------------------------------------------------}
  347.  
  348. function TPathEdExpert.GetComment: string;
  349. begin
  350.     Result := ''
  351. end;
  352.  
  353. {------------------------------------------------------------------------------}
  354.  
  355. function TPathEdExpert.GetGlyph: HICON;
  356. begin
  357.     Result := 0
  358. end;
  359.  
  360. {------------------------------------------------------------------------------}
  361.  
  362. function TPathEdExpert.GetMenuText: string;
  363. begin
  364.     Result := '';
  365. end;
  366.  
  367. {------------------------------------------------------------------------------}
  368.  
  369. function TPathEdExpert.GetPage: string;
  370. begin
  371.     Result := ''
  372. end;
  373.  
  374. {------------------------------------------------------------------------------}
  375.  
  376. function TPathEdExpert.GetState: TExpertState;
  377. begin
  378.     Result := []
  379. end;
  380.  
  381. { TfrmSetPath -----------------------------------------------------------------}procedure TfrmSetPath.SaveList;
  382. var
  383.  i : Integer;
  384.  
  385. begin
  386.     OldList.Clear;
  387.     for i := 0 to lstPath.Items.Count-1 do
  388.       OldList.AddObject(lstPath.Items[i],Pointer(Ord(lstPath.State[i])));
  389. end;
  390.  
  391. {------------------------------------------------------------------------------}
  392.  
  393. procedure TfrmSetPath.RestoreList;
  394. var
  395.  i : Integer;
  396.  
  397. begin
  398.     lstPath.Clear;
  399.     for i := 0 to OldList.Count-1 do
  400.   begin
  401.       lstPath.Items.Add(OldList[i]);
  402.     lstPath.State[i] := TCheckBoxState(OldList.Objects[i]);
  403.   end;
  404. end;
  405.  
  406. {------------------------------------------------------------------------------}
  407.  
  408. function TfrmSetPath.ListSaved : Boolean;
  409. begin
  410.     Result := OldList.Count > 0;
  411. end;
  412.  
  413. {------------------------------------------------------------------------------}
  414.  
  415. procedure TfrmSetPath.ParsePath;
  416. var
  417.     s, x : string;
  418.  
  419. begin
  420.     s := '';
  421.   x := '';
  422.  
  423.   with TRegistry.Create do
  424.   try
  425.       RootKey := HKEY_CURRENT_USER;
  426.     OpenKey(DELPHI_3_PATH, False);
  427.         s := ReadString(DELPHI_3_PATH_KEY);
  428.  
  429.     while s <> '' do
  430.     begin
  431.       lstPath.Items.Add(strToken(s,';'));
  432.       lstPath.State[lstPath.Items.Count-1] := cbChecked
  433.     end;
  434.   finally
  435.       Free;
  436.   end;
  437. end;
  438.  
  439. {------------------------------------------------------------------------------}
  440.  
  441. procedure TfrmSetPath.WritePath;
  442. var
  443.   i : Integer;
  444.   b : string;
  445.  
  446. begin
  447.     Path := '';
  448.  
  449.     for i := 0 to lstPath.Items.Count-1 do
  450.         if lstPath.State[i] = cbChecked then Path := Path + lstPath.Items[i] + ';';
  451.  
  452.     Path := Copy(Path,1,Length(Path)-1);
  453.  
  454.   with TRegistry.Create do
  455.   try
  456.       RootKey := HKEY_CURRENT_USER;
  457.     if not OpenKey(DELPHI_3_PATH,False) then Exit;
  458.     if not ValueExists(DELPHI_3_PATH_KEY) then Exit;
  459.  
  460.        WriteString(DELPHI_3_PATH_KEY, Path);
  461.  
  462.     // Clear out the values. Then Add them in.
  463.        DeleteKey(DELPHI_3_FULLPATH);
  464.        OpenKey(DELPHI_3_FULLPATH, True);
  465.         for i := 0 to lstPath.Items.Count-1 do
  466.     begin
  467.         if lstPath.State[i] = cbChecked
  468.       then b := 'T'
  469.       else b := 'F';
  470.  
  471.         WriteString(IntToStr(i),lstPath.Items[i]+','+b);
  472.     end;
  473.   finally
  474.       Free;
  475.   end;
  476. end;
  477.  
  478. {------------------------------------------------------------------------------}
  479.  
  480. procedure TfrmSetPath.ReadPath;
  481. var
  482.     s : string;
  483.   b: Boolean;
  484.     i : Integer;
  485.   KeyInfo : TRegKeyInfo;
  486.  
  487. begin
  488.     lstPath.Clear;
  489.  
  490.   with TRegistry.Create do
  491.   try
  492.       RootKey := HKEY_CURRENT_USER;
  493.     if not OpenKey(DELPHI_3_FULLPATH,False) then
  494.     begin
  495.         ParsePath;
  496.         Exit;
  497.         end;
  498.  
  499.         GetKeyInfo(KeyInfo);
  500.  
  501.         for i := 0 to KeyInfo.NumValues-1 do
  502.     begin
  503.         s := ReadString(IntToStr(i));
  504.         b := (Copy(s,Pos(',',s)+1,1) = 'T');
  505.         s := Copy(s,1,Pos(',',s)-1);
  506.         lstPath.Items.Add(s);
  507.             if b then lstPath.State[i] := cbChecked;
  508.     end;
  509.   finally
  510.       Free;
  511.   end;
  512. end;
  513.  
  514. {------------------------------------------------------------------------------}
  515.  
  516. procedure TfrmSetPath.SyncWithPackages;
  517. var
  518.   i : Integer;
  519.     s : string;
  520.  
  521. begin
  522.      SaveList;
  523.  
  524.   PackagePath.Clear;
  525.     with TRegistry.Create do
  526.   try
  527.  
  528.       RootKey := HKEY_CURRENT_USER;
  529.     if not OpenKey(DELPHI_3_KNOWN_PACKAGES,False) then Exit;
  530.  
  531.     GetValueNames(PackagePath);
  532.  
  533.     if DisplayPackagePath then
  534.           for i := 0 to PackagePath.Count-1 do
  535.         with PackagePath do
  536.         begin
  537.             s := ExtractFilePath(PackagePath[i]);
  538.           s := Copy(s,1,Length(s)-1);
  539.               if lstPath.Items.IndexOf(s) = -1 then
  540.           begin
  541.               Add(s);
  542.             lstPath.Items.Add(s);
  543.                       lstPath.State[lstPath.Items.Count-1] := cbChecked;
  544.           end;
  545.         end;
  546.   finally
  547.       Free;
  548.   end;
  549. end;
  550.  
  551. {------------------------------------------------------------------------------}
  552.  
  553. procedure TfrmSetPath.AddSubDirs(Sender: TObject);
  554. begin
  555. end;
  556.  
  557. {------------------------------------------------------------------------------}
  558.  
  559. procedure TfrmSetPath.SetDisplayPackagePath(Value : Boolean);
  560. begin
  561.   if FDisplayPackagePath <> Value then
  562.   begin
  563.     FDisplayPackagePath := Value;
  564.   end;
  565. end;
  566.  
  567. {------------------------------------------------------------------------------}
  568.  
  569. procedure TfrmSetPath.SetSyncPackages(Value : Boolean);
  570. begin
  571.   if FSyncPackages <> Value then
  572.   begin
  573.     FSyncPackages := Value;
  574.  
  575.     if FSyncPackages
  576.     then SyncWithPackages
  577.     else
  578.       if ListSaved then RestoreList;
  579.   end;
  580. end;
  581.  
  582. {------------------------------------------------------------------------------}
  583.  
  584. procedure TfrmSetPath.btnAddClick(Sender: TObject);
  585. var
  586.     s : string;
  587.   sl : TStringList;
  588.   i : Integer;
  589.  
  590. begin
  591.   with TBrowseFolder.Create(nil) do
  592.   try
  593.     Title := 'Add Directory to Library Search Path';
  594.     ShowPathInStatusArea := True;
  595.     CustomButtonVisible := True;
  596.     CustomButtonCaption := 'Add Sub Directories';
  597.     CustomButtonType := btCheckBox;
  598.     CustomButtonWidth := 150;
  599.       if Execute then
  600.           with lstPath do
  601.       begin
  602.         if ItemIndex < 0 then ItemIndex := 0;
  603.         // Adding SubDirs?
  604.         if CustomButtonChecked then
  605.         begin
  606.           sl := TStringList.Create;
  607.           sl.Clear;
  608.           try
  609.             ReadDirectoryNames(Directory+'\', sl);
  610.             for i := sl.Count-1 downto 0 do
  611.             begin
  612.               s := Directory+'\'+sl[i];
  613.                 if Items.IndexOf(s) = -1 then Items.Insert(ItemIndex,s);
  614.               State[Items.IndexOf(s)] := cbChecked;
  615.               ItemIndex := Items.IndexOf(s);
  616.             end;
  617.           finally
  618.             sl.Free;
  619.           end;
  620.         end;
  621.  
  622.         s := Directory;
  623.           if Items.IndexOf(s) = -1 then Items.Insert(ItemIndex,s);
  624.         State[Items.IndexOf(s)] := cbChecked;
  625.         ItemIndex := Items.IndexOf(s);
  626.       end;
  627.   finally
  628.     SetFocus;
  629.     Free;
  630.   end;
  631.  
  632.   StatusBar1.SimpleText := 'Path has been updated.';
  633. end;
  634.  
  635. {------------------------------------------------------------------------------}
  636.  
  637. procedure TfrmSetPath.btnRemoveClick(Sender: TObject);
  638. var
  639.   OldIndex : Integer;
  640.  
  641. begin
  642.     with lstPath do
  643.   begin
  644.     OldIndex := ItemIndex;
  645.         if ItemIndex > -1 then Items.Delete(ItemIndex);
  646.  
  647.     Dec(OldIndex);
  648.     if OldIndex < 0 then OldIndex := 0;
  649.     ItemIndex := OldIndex;
  650.   end;
  651.  
  652.   StatusBar1.SimpleText := 'Path has been updated.';
  653. end;
  654.  
  655. {------------------------------------------------------------------------------}
  656.  
  657. procedure TfrmSetPath.btnUpClick(Sender: TObject);
  658. var
  659.     s : string;
  660.  
  661. begin
  662.     with lstPath do
  663.         if ItemIndex > 0 then
  664.     begin
  665.         s := Items[ItemIndex];
  666.         Items.Exchange(ItemIndex, ItemIndex-1);
  667.       ItemIndex := Items.IndexOf(s);
  668.       SetFocus;
  669.     end;
  670. end;
  671.  
  672. {------------------------------------------------------------------------------}
  673.  
  674. procedure TfrmSetPath.btnDownClick(Sender: TObject);
  675. var
  676.     s : string;
  677.  
  678. begin
  679.     with lstPath do
  680.         if ItemIndex < Items.Count-1 then
  681.     begin
  682.         s := Items[ItemIndex];
  683.         Items.Exchange(ItemIndex, ItemIndex+1);
  684.       ItemIndex := Items.IndexOf(s);
  685.       SetFocus;
  686.     end;
  687. end;
  688.  
  689. {------------------------------------------------------------------------------}
  690.  
  691. procedure TfrmSetPath.FormClose(Sender: TObject; var Action: TCloseAction);
  692. begin
  693.     WritePath;
  694.     OldList.Free;
  695.   PackagePath.Free;
  696. end;
  697.  
  698. {------------------------------------------------------------------------------}
  699.  
  700. procedure TfrmSetPath.FormCreate(Sender: TObject);
  701. begin
  702.     OldList := TStringList.Create;
  703.   OldList.Clear;
  704.     ReadPath;
  705.  
  706.   PackagePath := TStringList.Create;
  707. end;
  708.  
  709. {------------------------------------------------------------------------------}
  710. procedure TfrmSetPath.FormStorageRestorePlacement(Sender: TObject);begin
  711.   with TRegistry.Create do
  712.   try
  713.       RootKey := HKEY_CURRENT_USER;
  714.     if not OpenKey(FormStorage.IniFileName+'\'+FormStorage.IniSection,False) then
  715.     begin
  716.         Exit;
  717.         end;
  718.  
  719.     if ValueExists('cbxDisplayPackages_Checked') then
  720.       FDisplayPackagePath := (ReadString('cbxDisplayPackages_Checked') = 'True');
  721.  
  722.     if ValueExists('cbxSync_Checked') then
  723.           SyncPackages := (ReadString('cbxSync_Checked') = 'True');
  724.   finally
  725.     Free;
  726.   end;
  727. end;
  728.  
  729. {------------------------------------------------------------------------------}
  730. procedure Register;begin
  731.     PathEdExpert := TPathEdExpert.Create;
  732.   RegisterLibraryExpert(PathEdExpert);
  733. end;
  734. {------------------------------------------------------------------------------}
  735. procedure TfrmSetPath.btnOptionsClick(Sender: TObject);begin
  736.   with TfrmPathOptions.Create(nil) do
  737.   try                          
  738.     if ShowModal = mrOK then
  739.     begin
  740.       DisplayPackagePath  := cbxDisplayPackages.Checked;
  741.       SyncPackages        := cbxSync.Checked;
  742.     end;
  743.   finally
  744.     Free;
  745.   end;
  746. end;
  747.  
  748. {------------------------------------------------------------------------------}
  749. procedure TfrmSetPath.Sort1Click(Sender: TObject);begin
  750.   lstPath.Sorted := True;
  751. end;
  752.  
  753. procedure TfrmSetPath.About1Click(Sender: TObject);
  754. begin
  755.   with TfrmrkAbout.Create(nil) do
  756.   try
  757.     Copyright := '⌐ Copyright 1997 Robert N. Kozak. All Rights Reserved.';
  758.     Version := 'Version 3.02';
  759.     AppName := 'Delphi Library Search Path Editor';
  760.     Title := 'About Delphi Library Search Path Editor';
  761.     SecretMessage := 'You found the Secret Message!';
  762.     ShowModal;
  763.   finally
  764.     Free;
  765.   end;
  766. end;
  767.  
  768. end.
  769.  
  770.